<?php
$cid = intval($_GET['cid']);
$page = intval($_GET['page']);
$type = $_GET['type'];
unset($_GET,$_POST,$_REQUEST);
require_once('global.php');

if($type == 'list'){
	if(!$cid) exit;
	!file_exists(D_P.'data/cache/cate_'.$cid.'.php') && exit;
	require_once(D_P.'data/cache/cate_'.$cid.'.php');
	if($cateinfo['path']){
		$filepath = $cateinfo['path'].'/';
	}else {
		$filepath = $cid.'/';
	}
	if($page>1){
		$listurl = $very['htmdir'].'/'.$filepath.'index_'.$page.'.'.$very['htmext'];
	}else{
		$listurl = $very['htmdir'].'/'.$cateinfo['listurl'];
	}
	if($cateinfo['listpub'] && $timestamp - filemtime($listurl) > $cateinfo['autoupdate']*60){
		require_once(R_P.'require/class_action.php');
		$action = new Action('publist');
		$action->cate($cid);
		$action->doIt();
	}else{
		$upTids = readover(D_P.'data/cache/updatelist_'.$cid.'.cache');
		if($upTids){
			if($upTids=='complete'){
				require_once(R_P.'require/class_action.php');
				$action = new Action('publist');
				$action->cate($cid);
				$action->doIt();
				writeover(D_P.'data/cache/updatelist_'.$cid.'.cache','');
			}else{
				$opnum = $very['opnum'] ? intval($very['opnum']) : 30;
				$upTids = explode('|',$upTids);
				$upTid = array_splice($upTids,0,$opnum);
				$upTids = implode('|',$upTids);
				empty($upTids) && $upTids = 'complete';
				writeover(D_P.'data/cache/updatelist_'.$cid.'.cache',$upTids);
				require_once(R_P.'require/class_action.php');
				$action = new Action('pubview');
				$action->cate($cid);
				$action->doIt($upTid);
			}
			
		}
	}
}elseif ($type == 'index'){
	if($timestamp - filemtime(R_P.'index.html') > $very['indexupdate']*60){
		require_once(R_P.'require/class_action.php');
		$action = new Action('pubindex');
		$action->doIt();
	}
}

exit();
?>